package com.scs.application.modules.msg.controller;

import com.scs.application.consts.GlobalConsts;
import com.scs.application.modules.base.annotation.MarkParameter;
import com.scs.application.modules.msg.dto.PushDTO;
import com.scs.application.modules.msg.service.PushService;
import com.scs.application.modules.sys.model.RestResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @version: 1.0
 * @description:
 */
@RestController
@RequestMapping("/msg/push")
public class PushController {

    @Autowired
    private PushService pushService;

    /**
     * 消息推送
     * @param dto
     * @return
     */
    @PostMapping
    @MarkParameter(type = GlobalConsts.MarkParameterTYpe.USER_MSG,msg = "用户站内消息")
    public RestResult push(@RequestBody @Valid PushDTO dto){
        pushService.pushByDTO(dto);
        return RestResult.ok();
    }

    /**
     * 消息推送(站内信、公告)
     * @param dto
     * @return
     */
    @PostMapping("/pushMessage")
    public RestResult pushMessage(@RequestBody @Valid PushDTO dto){
        pushService.pushMessage(dto);
        return RestResult.ok("消息推送成功!");
    }

}
